// ResponsiveIrregularShape class - ResponsiveIrregularShape element for scene - draws and manages a ResponsiveIrregularShape in the scene
// responsive shapes, consider their parameters as percentages
// Remark - boundaries are not done... so redrawing will not happen for this shape correctly
// the invalidation rules must be computed in the future

ResponsiveIrregularShape.prototype = new IrregularShape();  
ResponsiveIrregularShape.prototype.constructor=ResponsiveIrregularShape;
function ResponsiveIrregularShape(points){
	this.percentagePoints = points;	
	this.points = null;
	
	this.addPoint = function(point){
		if(!this.percentagePoints) this.percentagePoints = new Array();
		this.percentagePoints.push(point);
	}
	
	this.addedToScene = function(scene){
		
		scene.domUtils.addEventSimple(scene.canvas,"onresize", this.updateIrregularShape);
		this.updateIrregularShape();
	}
	this.updateIrregularShape = function(){		
		if(!this.scene)return;
		if(!this.percentagePoints)return;
		var sceneSize = scene.getSize();
		this.points = new Array();
		for(var i=0;i<this.percentagePoints.length;i++){
			var percentagePoint = this.percentagePoints[i];
			var point = {
				x : sceneSize.w * percentagePoint.x / 100,
				y : sceneSize.h * percentagePoint.y / 100,
			};
			this.points.push(point);
			if(i==0){
				this.x = point.x; this.y = point.y;
			}
			else{
				if(this.x>point.x) this.x = point.x;
				if(this.y>point.y) this.y = point.y;
			}
		}		
		this.updateBoundary();
	}

	
}
